package com.service.admin.trading.controller;

import com.service.admin.framework.log.RequestLog;
import com.service.admin.trading.controller.rep.SpotOrderDetailRep;
import com.service.admin.trading.controller.rep.SpotOrderPageRep;
import com.service.admin.trading.controller.req.CancelOrderReq;
import com.service.admin.trading.controller.req.SpotOrderPageReq;
import com.service.admin.trading.service.TradingSpotOrderService;
import com.service.core.rest.BaseController;
import com.service.core.rest.response.BaseResponse;
import com.service.core.rest.response.OneResponse;
import com.service.core.rest.response.PageResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("trading-spot-order")
public class TradingSpotOrderController extends BaseController {

    @Autowired
    private TradingSpotOrderService tradingSpotOrderService;

    @RequestLog("币币交易分页查询")
    @PostMapping("page")
    public PageResponse<SpotOrderPageRep> pageOrder(@RequestBody SpotOrderPageReq pageReq) {
        return successQueryPageResponse(tradingSpotOrderService.pageOrder(pageReq));
    }

    @RequestLog("币币交易详情")
    @GetMapping("detail/{orderNo}")
    public OneResponse<SpotOrderDetailRep> pageOrder(@PathVariable("orderNo") String orderNo) {
        return successQueryOneResponse(tradingSpotOrderService.orderDetail(orderNo));
    }

    @RequestLog("申请撤消币币交易")
    @PostMapping("apply-cancel/{tradeNo}")
    public BaseResponse applyCancelOrder(@PathVariable("tradeNo") String tradeNo) {
        tradingSpotOrderService.applyCancelSpotOrder(tradeNo);
        return successBaseResponse();
    }

    @RequestLog("批量申请撤消币币交易")
    @PostMapping("batch-apply-cancel")
    public BaseResponse applyBatchCancelOrder(@RequestBody CancelOrderReq cancelOrderReq) {
        tradingSpotOrderService.applyBatchCancelSpotOrder(cancelOrderReq);
        return successBaseResponse();
    }


}
